package com.example.orderserver.biz;


import com.example.orderserver.pojo.employee;
import org.apache.tomcat.util.buf.UEncoder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;


@Service
public class employeeBiz {

    @Autowired
    private RestTemplate restTemplate;

    public employee list(String id){



        String url  = "http://userserver/userserver/user/"+id;
        employee user= restTemplate.getForObject(url,employee.class);

        return  user;
    }

    public List<employee> selectall(){
        String url  = "http://userserver/userserver/selectall";

        employee[] list=  restTemplate.getForObject(url,employee[].class);
        return  Arrays.asList(list);
    }

    public  void deleteByid(Integer id){
        String url  = "http://userserver/userserver/deleteByid/"+id;
        Integer num=restTemplate.getForObject(url,Integer.class);
        System.out.println("删除");

    }

    public  Integer inserts(employee employee){
        String url  = "http://userserver/userserver/inserts";
        Integer num=restTemplate.getForObject(url,Integer.class,employee);
        return  num;
    }

    public Integer updateByid(employee employee){
        String url  = "http://userserver/userserver/updateByid";
        Integer num=restTemplate.getForObject(url,Integer.class,employee);
        return  num;
    }

}